﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StateTheater.Controllers
{
    using Castle.MonoRail.Framework;
    using Castle.MonoRail.Framework.Helpers;

    public class AspController : SmartDispatcherController
    {
        public void Default()
        {
            string query = Params["QUERY_STRING"]; 

            if (query != null && query.Length > 1)
            {
                Char page = query[0];
                int id;
                if (Int32.TryParse(query.Substring(1), out id))
                {
                    switch (page)
                    {
                        case 'T':
                            Troupe(id);
                            break;

                        case 'P':
                            Person(id);
                            break;

                        case 'V':
                            Venue(id);
                            break;

                        default:
                            Playing();
                            break;
                    }
                }
            }
            else
                Playing();
        }
        public void Playing()
        {
            this.Redirect("Show", "Playing");
        }

        public void Troupe(int id)
        {
            Redirect("Troupe", "Display", DictHelper.CreateN("id", id));
        }

        public void Venue(int id)
        {
            Redirect("Venue", "Display", DictHelper.CreateN("id", id));
        }

        public void Person(int id)
        {
            Redirect("Person", "Display", DictHelper.CreateN("id", id));
        }
    }
}
